package edu.fmi.st.epf.types.skill.ui.provider;

import java.util.Collection;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.epf.uma.UmaPackage;
import org.eclipse.swt.graphics.Image;

import edu.fmi.st.epf.types.skill.common.util.SkillHelper;
import edu.fmi.st.epf.types.skill.ui.SkillActivator;
import eu.tanov.epf.itemprovider.extension.CustomItemProvider;

public class SkillItemProvider extends BaseSkillsItemProvider implements
		CustomItemProvider {

	public SkillItemProvider() {
		this(null);
	}

	public SkillItemProvider(AdapterFactory adapterFactory) {
		super(adapterFactory);
	}

	@SuppressWarnings("unchecked")
	@Override
	public void collectNewChildDescriptors(
			@SuppressWarnings("rawtypes") Collection newChildDescriptors,
			Object object) {
		newChildDescriptors.clear();
		if (SkillHelper.isSkillGroup(object)) {
			newChildDescriptors.add(createChildParameter(
					UmaPackage.eINSTANCE.getContentPackage_ContentElements(),
					SkillHelper.makeCategory(SkillHelper.MAKE_SKILL_TEXT)));
			newChildDescriptors.add(createChildParameter(
					UmaPackage.eINSTANCE.getContentPackage_ContentElements(),
					SkillHelper.makeCategory(SkillHelper.MAKE_GROUP_TEXT)));
		}
	}

	public boolean matches(Object object) {
		return SkillHelper.isSkill(object);
	}

	public static Image getSkillImage() {
		return SkillActivator.getDefault().getImage("full/obj/Skill"); //$NON-NLS-1$
	}

}
